package com.example.guide.scheduling;


import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.stereotype.Service;

import java.util.concurrent.Future;

/**
 * 多线程
 * */
@Service
public class TaskService {

    @Async("Amos-ThreadPool1")
    public void excutVoidTask() {
        System.out.println("excutVoidTask : " + Thread.currentThread().getId()  + ":" + Thread.currentThread().getName());
    }

    @Async("Amos-ThreadPool2")
    public Future<String> excuteValueTask() throws InterruptedException {
        Future<String> future = new AsyncResult<String>("success");
        System.out.println("excuteValueTask :"   + Thread.currentThread().getId()  + ":" + Thread.currentThread().getName() );
        return future;
    }


}